﻿using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using DataFileApplication_WPF.Helper;
using Newtonsoft.Json.Linq;

namespace DataFileApplication_WPF.Models
{
    [Serializable]
    public class DataGridComment : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        private LanguageComment _languageComments;

        public LanguageComment LanguageComments
        {
            get { return _languageComments; }
            set
            {
                _languageComments = value;
                this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(LanguageComments)));
            }
        }



        public ObservableCollection<object> ValueList { get; set; }

        public DataGridComment()
        {
            LanguageComments = new LanguageComment();
            ValueList = new ObservableCollection<object>();
        }



        public DataGridComment Clone()
        {
            // 创建一个新的 DataGridComment 对象并复制属性
            return new DataGridComment
            {
                LanguageComments = this.LanguageComments,
                ValueList = this.ValueList
            };
        }
    }

    [Serializable]
    public class LanguageComment : INotifyPropertyChanged
    {

        private Dictionary<string, string> _languageCommentsDic;
        public Dictionary<string, string> LanguageCommentsDic
        {
            get { return _languageCommentsDic; }
            set { _languageCommentsDic = value; }
        }
 
        private string _currentlanguageComment;

        public string CurrentlanguageComment
        {
            get
            {
                if (_languageCommentsDic.Count != 0)
                {
                    return _languageCommentsDic[LanguageManager.GetCurrentLanguage()];
                }
                else
                {
                    return null;
                }
            }
            set
            {
                if (_languageCommentsDic.Count != 0)
                {
                    _currentlanguageComment = value;
                    if (_languageCommentsDic.ContainsKey(LanguageManager.GetCurrentLanguage()))
                    {
                        _languageCommentsDic[LanguageManager.GetCurrentLanguage()] = value;
                    }
                    else
                    {
                        _languageCommentsDic.Add(LanguageManager.GetCurrentLanguage(), value);
                    }
                }
                this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(CurrentlanguageComment)));
            }
        }




        public LanguageComment()
        {
            _languageCommentsDic = new Dictionary<string, string>();
        }

        public event PropertyChangedEventHandler PropertyChanged;

        public LanguageComment Clone()
        {
            // 创建一个新的 DataGridComment 对象并复制属性
            return new LanguageComment
            {
                LanguageCommentsDic = this.LanguageCommentsDic,
                CurrentlanguageComment = this.CurrentlanguageComment
            };
        }
    }
}
